/*
 *  Produit.java                   8 Mars 2011
 */

package isi.corba.entites;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;

/**
 *
 */
@Entity
public class Produit implements Serializable {
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    /**
     * Le libelle du produit
     */
    @Column(nullable=false, length=30)
    private String libelle;
    
    @Column(nullable=false)
    private String descriptif;

    @ManyToOne(fetch= FetchType.EAGER)
    @JoinColumn(name= "fk_categorie", nullable=false)
    private SousCategorie sousCategorie;

    @ManyToOne(fetch= FetchType.EAGER)
    @JoinColumn(name= "fk_client", nullable=false)
    private Client vendeur;

    @Column(nullable=false)
    private int prixDepart;

    @Column(nullable=false)
    private int prixAchatImmediat;

    @Column(name = "date_fin", nullable = true)
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date dateEcheance;




    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Date getDateEcheance() {
        return dateEcheance;
    }

    public void setDateEcheance(Date dateEcheance) {
        this.dateEcheance = dateEcheance;
    }

    public String getDescriptif() {
        return descriptif;
    }

    public void setDescriptif(String descriptif) {
        this.descriptif = descriptif;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public int getPrixAchatImmediat() {
        return prixAchatImmediat;
    }

    public void setPrixAchatImmediat(int prixAchatImmediat) {
        this.prixAchatImmediat = prixAchatImmediat;
    }

    public int getPrixDepart() {
        return prixDepart;
    }

    public void setPrixDepart(int prixDepart) {
        this.prixDepart = prixDepart;
    }

    public SousCategorie getSousCategorie() {
        return sousCategorie;
    }

    public void setSousCategorie(SousCategorie sousCategorie) {
        this.sousCategorie = sousCategorie;
    }

    public Client getVendeur() {
        return vendeur;
    }

    public void setVendeur(Client vendeur) {
        this.vendeur = vendeur;
    }

    

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Produit)) {
            return false;
        }
        Produit other = (Produit) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "isi.corba.entites.Produit[id=" + id + "]";
    }

}
